/**
 * 
 */
package org.corpus.english.web;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.InputStream;

import org.zkoss.zk.ui.WebApp;
import org.zkoss.zk.ui.util.WebAppInit;

/**
 * @author robbiecheng
 *
 */
public class EnglishAppInit implements WebAppInit{

	public void init(WebApp app) throws Exception {
		
		String filePath = app.getRealPath("/") + "commonwords.txt";
		String words = "";
        File file = new File(filePath);
        if (file.exists()){
			BufferedReader input = new BufferedReader(new FileReader(file));
			String str;
			while ((str = input.readLine()) != null)
				words += (str + " ");
			input.close();
			app.setAttribute("commonwords", words);
		}
		else
			System.out.println("cannot find commonwords.txt");
		
	}

}
